<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>大小写转换</title>
</head>
<body>
<input type="text" oninput="trans(this)" id="shuru">
<h1 id="titl"></h1>
<script>

    var titl=document.getElementById('titl');

    function trans(e) {
        var str = shuru.value;//拿到输入的字符串
        for (var i = 0; i < str.length; i++) {
            var bianMa = str.charCodeAt(i);//得到输入的每个字符的编码(这是一个数组);
            var daxie=String.fromCharCode(bianMa-32);//将输入的字符串的编码-32，并将其转换为大写
        }

        titl.innerHTML += daxie;
    }
</script>
</body>
</html>